package com.example.sps.mapper;

import com.example.sps.pojo.dto.CommonPageQueryDTO;
import com.example.sps.pojo.dto.HomeProductQueryDTO;
import com.example.sps.pojo.dto.ProjectQueryDTO;
import com.example.sps.pojo.dto.SmProductQueryDTO;
import com.example.sps.pojo.entity.*;
import com.example.sps.pojo.vo.*;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {

    Page<ParameterListVO> parameterPageQuery(CommonPageQueryDTO commonPageQueryDTO);

    void updateParam(Parameter parameter);

    void insertParam(Parameter parameter);

    @Delete("delete from t_parameter where id = #{id}")
    void deleteParamById(Integer id);

    @Select("select * from t_parameter where id = #{id}")
    Parameter getParamById(Integer id);

    void deleteParamBatch(List<Integer> ids);

    @Update("update t_parameter set status = #{status},modify_emp_id=#{modifyEmpId},modify_time=#{modifyTime}" +
            " where id=#{id};")
    void updateParamStatus(Parameter parameter);

    Page<SmClassVO> smClassPageQuery(CommonPageQueryDTO commonPageQueryDTO);

    void insertSmClass(SmClass smClass);

    void updateSmClass(SmClass smClass);

    @Update("update t_sm_class set status = #{status},modify_emp_id=#{modifyEmpId},modify_time=#{modifyTime}" +
            " where id=#{id};")
    void updateSmClassStatus(SmClass smClass);

    void insertSmProduct(SmProduct smProduct);

    @Insert("insert into t_param_product (product_id, param_id, detail) values (#{productId},#{paramId},#{detail})")
    void insertParamProduct(ParamProduct paramProduct);

    @Select("select * from t_sm_class where id=#{id}")
    SmClass getSmClassById(Integer id);

    @Select("select * from t_sm_product where class=#{classId}")
    List<SmProduct> getSmProductByClassId(Integer classId);

    @Select("select * from t_param_product where param_id=#{paramId}")
    List<ParamProduct> getParamProductByParamId(Integer paramId);

    void deleteSmClassBatch(List<Integer> ids);

    @Delete("delete from t_sm_class where id=#{id}")
    void deleteSmClassById(Integer id);

    Page<SmProductVO> smProductPageQuery(SmProductQueryDTO smProductQueryDTO);

    void updateSmProduct(SmProduct smProduct);

    @Delete("delete from t_param_product where product_id=#{productId}")
    void deleteParamProductByProductId(Long productId);

    @Update("update t_sm_product set status=#{status},modify_emp_id=#{modifyEmpId},modify_time=#{modifyTime} where id=#{id}")
    void updateSmProductStatus(SmProduct smProduct);

    @Select("select * from t_sm_product where id = #{id}")
    SmProduct getSmProductById(Long id);

    @Select("select * from t_param_product where product_id = #{productId}")
    List<ParamProduct> getParamProductByProductId(Long id);

    @Delete("delete from t_sm_product where id  =#{id}")
    void deleteSmProductById(Long id);

    Page<HomeClassVO> homeClassPageQuery(CommonPageQueryDTO commonPageQueryDTO);

    void insertHomeClass(HomeClass homeClass);

    void updateHomeClass(HomeClass homeClass);
    @Update("update t_home_class set status = #{status},modify_emp_id=#{modifyEmpId},modify_time=#{modifyTime}" +
            " where id=#{id};")
    void updateHomeClassStatus(HomeClass homeClass);

    @Select("select * from t_home_class where id=#{id}")
    HomeClass getHomeClassById(Integer id);

    @Select("select * from t_home_product where class=#{id}")
    List<HomeProduct> getHomeProductByClassId(Integer id);

    @Delete("delete from t_home_class where id=#{id}")
    void deleteHomeClassById(Integer id);

    void deleteHomeClassBatch(List<Integer> ids);

    void insertHomeProduct(HomeProduct homeProduct);

    Page<HomeProductVO> homeProductPageQuery(HomeProductQueryDTO homeProductQueryDTO);

    void updateHomeProduct(HomeProduct homeProduct);

    @Update("update t_home_product set status=#{status},modify_emp_id=#{modifyEmpId},modify_time=#{modifyTime} where id=#{id}")
    void updateHomeProductStatus(HomeProduct homeProduct);

    @Select("select * from t_home_product where id =#{id}")
    HomeProduct getHomeProductById(Long id);

    @Delete("delete from t_home_product where id = #{id}")
    void deleteHomeProductById(Long id);

    void insertProject(Project project);

    Page<ProjectVO> projectPageQuery(ProjectQueryDTO projectQueryDTO);

    void updateProject(Project project);

    @Update("update t_project set status=#{status},modify_emp_id=#{modifyEmpId},modify_time=#{modifyTime} where id=#{id}")
    void updateProjectStatus(Project project);

    @Select("select * from t_project where id = #{id}")
    Project getProjectById(Integer id);

    @Delete("delete from t_project where id=#{id}")
    void deleteProjectById(Integer id);

    void deleteProjectBatch(List<Integer> ids);
}
